package com.example.replacebooks.controller;


import com.example.replacebooks.common.Result;
import com.example.replacebooks.entity.Bookorder;
import com.example.replacebooks.entity.Orders_Bookorder;
import com.example.replacebooks.entity.Params;
import com.example.replacebooks.service.BookorderService;
import com.example.replacebooks.service.Orders_BookorderService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 订单信息 前端控制器
 * </p>
 *
 * @author replacebooks
 * @since 2025-03-03
 */
@CrossOrigin //解决跨域问题
@RestController
@RequestMapping("/orders_bookorder")
public class Orders_BookorderController {
    private static final Logger log = LoggerFactory.getLogger(OrderController.class);

    @Resource
    private Orders_BookorderService orders_bookorderService;

    @GetMapping
    public Result findAll(){return Result.success(orders_bookorderService.findAll());}

    @GetMapping("/search")
    public Result findBySearch(Params params){
        PageInfo<Orders_Bookorder> info = orders_bookorderService.findBySearch(params);
        return Result.success(info);
    }

    @PostMapping("/add")
    public Result add(@RequestBody Orders_Bookorder orders_bookorder){
        orders_bookorderService.add(orders_bookorder);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id){
        orders_bookorderService.delete(id);
        return Result.success();
    }
}
